<%@ page import="java.util.List" %>
<%@ page import="org.wanho.manager.entity.User" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title></title>
    <link rel="stylesheet" href="manager/css/style.css">
</head>
<body>
    <h3>用户管理</h3>
    <p>欢迎您：${sessionScope.username}</p>    <a href="${pageContext.request.contextPath}/logout">注销</a>
    <table>
        <thead>
            <tr>
                <th>序号</th>
                <th>账号</th>
                <th>密码</th>
                <th>角色</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
        <%
            List<User> users = (List<User>) request.getAttribute("users");
            for(int i=0;i<users.size();i++){
                User u = users.get(i);
        %>
            <tr>
                <td><%=i+1%></td>
                <td><%=u.getLoginName()%></td>
                <td><%=u.getPassword()%></td>
                <td>
                    <%
                        if(u.getRole().getRoleName().equals("administrator")){
                            out.print("管理员");
                        }else if(u.getRole().getRoleName().equals("teacher")){
                            out.print("教师");
                        }else if(u.getRole().getRoleName().equals("student")){
                            out.print("学生");
                        }
                    %>
                </td>
                <td>
                    <button onclick="">修改</button>
                    <button>删除</button>
                </td>
            </tr>
        <%
            }
        %>
        </tbody>
    </table>

    <a href="manager/role.jsp">角色管理</a>
</body>
</html>
